package com.atguigu05._super.exer3;

/**
 * ClassName: PersonTest
 * Description:
 *
 * @Author liu
 * @Create 2024/10/27 22:44
 * @Version 1.0
 */
public class Account {
    private int id;
    private double balance;
    private double annuallnterestRate;//年利率

    public Account(){

    }


    public Account(int id, double balance, double annuallnterestRate) {
        this.balance = balance;
        this.id = id;
        this.annuallnterestRate = annuallnterestRate;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public double getBalance() {
        return balance;
    }

    public void setBalance(double balance) {
        this.balance = balance;
    }

    public double getAnnuallnterestRate() {
        return annuallnterestRate;
    }

    public void setAnnuallnterestRate(double annuallnterestRate) {
        this.annuallnterestRate = annuallnterestRate;
    }

    /**
     * 月利率
     * @return
     */
    public double getMonthlyInterest(){
        return annuallnterestRate / 12;
    }

    /**
     * 取钱
     * @param amount
     */
    public void withdraw(double amount){
        if(balance >= amount){
            balance -=amount;
        }else{
            System.out.println("余额不足");
        }
    }

    public void deposit(double amount){
        if(amount > 0){
            balance += amount;
        }
    }


}
